import { type App } from 'vue'
import { notification } from 'ant-design-vue'
import { Notification as CoreNotification } from '@idmy/core'

export interface NotificationProps {
	content: string
	duration?: number
	onClose?: () => void
	position: any
	title: string
}

const install = (app: App) => {
	CoreNotification.success = (props: NotificationProps) => {
		return notification.success({
			description: props.content,
			duration: props.duration,
			message: props.title,
			onClose: props.onClose,
			placement: props.position,
		})
	}
	CoreNotification.error = (props: NotificationProps) => {
		return notification.error({
			description: props.content,
			duration: props.duration,
			message: props.title,
			onClose: props.onClose,
			placement: props.position,
		})
	}
	CoreNotification.warn = (props: NotificationProps) => {
		return notification.warn({
			description: props.content,
			duration: props.duration,
			message: props.title,
			onClose: props.onClose,
			placement: props.position,
		})
	}
	CoreNotification.info = (props: NotificationProps) => {
		return notification.info({
			description: props.content,
			duration: props.duration,
			message: props.title,
			onClose: props.onClose,
			placement: props.position,
		})
	}
	CoreNotification.close = (id: string) => notification.close(id)
	CoreNotification.clear = () => notification.destroy()
}

export default {
	install,
}
